/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package carrello.impl.boundary.manager;

import carrello.impl.boundary.AbstractUI;
import carrello.impl.controller.manager.ViewInventoryCTRL;
import carrello.model.entities.Product;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Usman
 */
public class ViewInventoryUI extends AbstractUI{
    private LinkedList<LinkedList<String>> parameters;
    
    public LinkedList<LinkedList<String>> getParameters () {
        return parameters;
    }
    private void buildInventoryData () {
        parameters = new LinkedList<LinkedList<String>> ();
        List<Product> products = ViewInventoryCTRL.getAllProducts ();
        for ( Product p: products) {
            LinkedList<String> parameter = new LinkedList<String> ();
            parameter.add (p.getName());
            parameter.add (String.valueOf(p.getQuantity()));
            parameter.add (p.getPrice());
            parameters.add (parameter);
        }
    }
    public String execute () {
        if ( !getSessionIsLoggedIn())
            return ERROR;
        buildInventoryData ();
        return INPUT;
    }
    
}
